manage stored files via web

manage stored files via web

am 20.03.2003 11:46:45 von Victor Yegorov

--IJpNTDwzlM2Ie8A6
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hello.

Sorry for off-topic, but...

I have the following problem. I'm developing system with ability to store
files inside it. Files are being stored in postgres as large objects.

The problem is, that actual file names are stored along with LO oids. When
user wants to download some file, it clicks on link: "...?oid=3D&actio=
n=3Dget"
and browser suggests strange name for file being downloaded (currently it
suggests domain name or link text as file name).

What I want is that file name suggested by browser would be the one, stored
in DB. I currently enclose it in Content-type: HTTP header, but that seems
to be not working.


Thanks in advance.

--=20

Victor Yegorov

--IJpNTDwzlM2Ie8A6
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+eZwV2RKGLEykUDYRAiaVAKCVfgXRdojKuhg2c1XBPjROcV924gCd FWip
o6RQqvJI+kR7wLOYnIUK2Q8=
=PLas
-----END PGP SIGNATURE-----

--IJpNTDwzlM2Ie8A6--

Re: manage stored files via web

am 20.03.2003 11:53:12 von Grant Henderson

It would be better if you haven't gone to far already to save the files
into an level above the web directory and simply save the link to the
file into a varchar in the DB.
Then just call the link into an .

G

-----Original Message-----
From: Victor Yegorov [mailto:viy@pirmabanka.lv]=20
Sent: 20 March 2003 10:47
To: Postgres PHP
Subject: [PHP] manage stored files via web


Hello.

Sorry for off-topic, but...

I have the following problem. I'm developing system with ability to
store files inside it. Files are being stored in postgres as large
objects.

The problem is, that actual file names are stored along with LO oids.
When user wants to download some file, it clicks on link:
"...?oid=3D&action=3Dget" and browser suggests strange name for file
being downloaded (currently it suggests domain name or link text as file
name).

What I want is that file name suggested by browser would be the one,
stored in DB. I currently enclose it in Content-type: HTTP header, but
that seems to be not working.


Thanks in advance.

--=20

Victor Yegorov

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

Re: manage stored files via web

am 20.03.2003 12:03:42 von Victor Yegorov

--WplhKdTI2c8ulnbP
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Grant Henderson [20.03.2003 12:58]:
> It would be better if you haven't gone to far already to save the files
> into an level above the web directory and simply save the link to the
> file into a varchar in the DB.
> Then just call the link into an
.
>=20

I'm saving them not directly on my disk, I store them inside my POstgreSQL
database as Large Object.

--=20

Victor Yegorov

--WplhKdTI2c8ulnbP
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+eaAO2RKGLEykUDYRAs0zAJ4qJTwcdINyxgq5guhZ2JgwU2FPrgCg wjBo
6VMSSYMUKPkYfspIxVAsvv4=
=n8X5
-----END PGP SIGNATURE-----

--WplhKdTI2c8ulnbP--

Re: manage stored files via web

am 20.03.2003 14:29:05 von Victor Yegorov

--VMt1DrMGOVs3KQwf
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* Matt Palmer [20.03.2003 13:18]:
> are the jpegs only memory-resident or are they actually on-disk at any po=
int??

Nor memory resident, neither on disk. They are inside DB, to extract them i
need to use pg_lo_open, pg_lo_read funcs. Then I have a string, containing
file data. And I don't want to store them on disk, I'd like to output them
directly, specifing the name of the file somehow.

But how?

--=20

Victor Yegorov

--VMt1DrMGOVs3KQwf
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+ecIh2RKGLEykUDYRArMEAKCpnim1Z86Yx9i+mMJbNr3RjnsHsQCf Q1gy
izvw7V3OpV+0WXIXtlBbkrY=
=MbhL
-----END PGP SIGNATURE-----

--VMt1DrMGOVs3KQwf--

Re: manage stored files via web

am 20.03.2003 14:41:43 von apz

On Thu, 20 Mar 2003, Victor Yegorov wrote:
> What I want is that file name suggested by browser would be the one, stored
> in DB. I currently enclose it in Content-type: HTTP header, but that seems
> to be not working.

content-type, as name sais, is to suggest a 'type' of the file, should
browser try to show the file (in case its plaintext/html) or should it
call a plugin (ms word = "application/msword").

What you want is you want to suggest that
1. browser saves the file
2. browser use different name than the url one.

for this purpose you got in header option to do "Content-Disposition".
Here I must warn you that IE expects Content-Disposition handled
differently than other browsers. Here is what I used to do:

----
$myfakefilename = readFileName_FromDB();
if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) // For IE
header("Content-Disposition: filename=$myfakefilename" . "%20");
else // For Other browsers
header("Content-Disposition: attachment; filename=$myfakefilename");
----

enjoy,


/apz, Sometimes you get an almost irresistible urge to go on living.


---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Re: manage stored files via web

am 20.03.2003 15:30:58 von Victor Yegorov

--k3qmt+ucFURmlhDS
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* apz [20.03.2003 15:37]:
> On Thu, 20 Mar 2003, Victor Yegorov wrote:
> > What I want is that file name suggested by browser would be the one, st=
ored
> > in DB. I currently enclose it in Content-type: HTTP header, but that se=
ems
> > to be not working.
>=20
> content-type, as name sais, is to suggest a 'type' of the file, should=20
> browser try to show the file (in case its plaintext/html) or should it=20
> call a plugin (ms word =3D "application/msword").
>=20
> What you want is you want to suggest that=20
> 1. browser saves the file
> 2. browser use different name than the url one.
>=20
> for this purpose you got in header option to do "Content-Disposition".=20
> Here I must warn you that IE expects Content-Disposition handled=20
> differently than other browsers. Here is what I used to do:
>=20
> ----
> $myfakefilename =3D readFileName_FromDB();
> if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) // For IE
> header("Content-Disposition: filename=3D$myfakefilename" . "%20");=20
> else // For Other browsers
> header("Content-Disposition: attachment; filename=3D$myfakefilename");=
=20
> ----

Great, exactly what I needed.

One question - what for is "%20"? Explorer adds "[1]" suffix, when this
space present. I've removed it.


Thank you.

--=20

Victor Yegorov

--k3qmt+ucFURmlhDS
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE+edCi2RKGLEykUDYRAtSIAJ9M+630Bd11gv6PfXpk0IZJrSX9uwCg 1wL8
VaBUrF62cFIZ4OtLsaEtN8c=
=R+Ge
-----END PGP SIGNATURE-----

--k3qmt+ucFURmlhDS--

Re: manage stored files via web

am 20.03.2003 15:56:38 von apz

On Thu, 20 Mar 2003, Victor Yegorov wrote:
> * apz [20.03.2003 15:37]:
> > On Thu, 20 Mar 2003, Victor Yegorov wrote:
> > > What I want is that file name suggested by browser would be the one, stored
> > > in DB. I currently enclose it in Content-type: HTTP header, but that seems
> > > to be not working.
> > for this purpose you got in header option to do "Content-Disposition".
> > Here I must warn you that IE expects Content-Disposition handled
> > differently than other browsers. Here is what I used to do:
> > ----
> > $myfakefilename = readFileName_FromDB();
> > if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) // For IE
> > header("Content-Disposition: filename=$myfakefilename" . "%20");
> > else // For Other browsers
> > header("Content-Disposition: attachment; filename=$myfakefilename");
> > ----
> Great, exactly what I needed.
>
> One question - what for is "%20"? Explorer adds "[1]" suffix, when this
> space present. I've removed it.

actually I dont really know, i found it somewhere on the net. As I was
working with embedding documents from db (item with item image in db as
well), the content-disposition was actually causing problems for some
browsers as they assumed that although the file is to be embedded src=getImage.php?itemcode=9346a> browsers got confused by the
content-disposition and were assuming that download is necessary. As I
really didnt need to use content-disposition I removed teh code. I know
now that there is also content-disposition inline (vs attachment).

you can read more on content-disposition at:
http://www.php.net/manual/en/function.header.php


/apz, pain, n.: One thing, at least it proves that you're alive!


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org